package edu.sctu.lab03;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.SQLException;
import java.util.List;

/**
 * Created by Adminitrator on 2018/5/28.
 */
public class UserListServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req,
                         HttpServletResponse resp)
            throws ServletException, IOException {
        //中文乱码问题
//        resp.setHeader("content-type","text/html;charset=UTF-8");
//        PrintWriter out=resp.getWriter();

//        out.write("<table>");
//        out.write("<tr>");
//        out.write("<td>编号</td>");
//        out.write("<td>用户名</td>");
//        out.write("<td>密码</td>");
//        out.write("<td>操作1</td>");
//        out.write("<td>操作2</td>");
//        out.write("</tr>");
//        out.write("<tr>");
//        out.write("<td>1001</td>");
//        out.write("<td>yin</td>");
//        out.write("<td>123</td>");
//        out.write("<td>删除</td>");
//        out.write("<td>更新</td>");
//        out.write("</tr>");
//        out.write("</table>");

        Database database=new Database();
        List<User> userList=database.getUserList();

        req.setAttribute("userList",userList);
        req.getRequestDispatcher("/userList.jsp").forward(req,resp);



    }
}
